<?php
    $con = mysqli_connect('localhost','xin','123456','xin');

    // $sql = "SELECT * FROM `student` WHERE `age` = 20";
    // $sql = "DELETE FROM `student` WHERE `name` LIKE '%一%'";
    // $sql = "UPDATE `student` SET `gender` = '男' WHERE `id` = 4 ";
    // $sql = "INSERT INTO `student` (`id`, `name`, `age`, `gender`, `class`, `score`) VALUES (null, '吵吵', '23', '女', '1910', '100')";
    // $sql1 = "SELECT * FROM `student` WHERE `name` LIKE '吵吵' ORDER BY `age` ASC";
    
    // $res = mysqli_query($con,$sql);
    // $res1 = mysqli_query($con,$sql1);
    // if(!$res){
    //     die(mysqli_error($con));
    // }
    // $row1 = mysqli_fetch_assoc($res1)
    // 如果有数据被执行 有返回值
    // print_r($res);
    //print_r(json_encode($row1,JSON_UNESCAPED_UNICODE));
    $sql = "SELECT * FROM `student` WHERE `name` LIKE '%九%' ORDER BY `age` DESC";

    $res = mysqli_query($con,$sql);

    if(!$res){
        // . 在PHP中 作用 拼接：
        // js：name +'sdjfhsd'
        // PHP：$name . 'sdfdsh'
        die('数据库链接错误:' . mysqli_error($con));
    }

    $arr = array();
    $row = mysqli_fetch_assoc($res);
    while($row){
        array_push($arr,$row);
        $row = mysqli_fetch_assoc($res);
    }

    print_r(json_encode($arr,JSON_UNESCAPED_UNICODE));

    mysqli_close($con);

?>